package org.momo.rpc.protocol;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RpcResponse implements Serializable {

    private String message;

    private Class<?> dataType;

    private Object data;

    public static RpcResponse success(Object data, Class<?> dataType) {
        RpcResponse rpcResponse = new RpcResponse();
        rpcResponse.setMessage("success");
        rpcResponse.setDataType(dataType);
        rpcResponse.setData(data);
        return rpcResponse;
    }

    public static RpcResponse fail(String message) {
        RpcResponse rpcResponse = new RpcResponse();
        rpcResponse.setMessage(message);
        return rpcResponse;
    }

}
